﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Web.Services.Description;
using CourseBook;

namespace CourseBook
{
    public class clEduLevel
    {
        #region Khai bao

        private int _EduLevelID;
        private string _EduLevelName;
        private string _EduLevelNote;
        private string _EduLevelShortName;

        SqlConnection con;
        SqlCommand cmd;
        IDataAdapter da;
        DataSet ds;

        string str = ConfigurationManager.ConnectionStrings["ConnectionStrings"].ConnectionString;

        public int EduLevelID
        {
            get { return _EduLevelID; }
            set { _EduLevelID = value; }
        }
        public string EduLevelName
        {
            get { return _EduLevelName; }
            set { _EduLevelName = value; }
        }
        public string EduLevelNote
        {
            get { return _EduLevelNote; }
            set { _EduLevelNote = value; }
        }
        public string EduLevelShortName
        {
            get { return _EduLevelShortName; }
            set { _EduLevelShortName = value; }
        }
        #endregion
        //public void EduLevel_Load()
        //{
        //    ds = new DataSet();
        //    using (con = new SqlConnection(str))
        //    {
        //        con.Open();
        //        cmd = new SqlCommand("EduLevel_Load",con);
        //        cmd.CommandType = CommandType.StoredProcedure;
        //        da = new SqlDataAdapter(cmd);
        //        da.Fill(ds);
        //        con.Close();
        //    }
        //}
        public void EduLevel_Insert()
        {
            using (con = new SqlConnection(str))
            {
                
                try
                {
                    con.Open();
                    cmd = new SqlCommand("EduLevel_Insert", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@EduLevelName", _EduLevelName);
                    cmd.Parameters.Add("@EduLevelNote", _EduLevelNote);
                    cmd.Parameters.Add("@EduLevelShortName", _EduLevelShortName);
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                catch (Exception)
                {
                   
                }
            }
        }
        public void EduLevel_Update()
        {
            using (con = new SqlConnection(str))
            {
                con.Open();
                cmd = new SqlCommand("EduLevel_Update",con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Name", _EduLevelName);
                cmd.Parameters.Add("@Note", _EduLevelNote);
                cmd.Parameters.Add("@ShortName", _EduLevelShortName);
                try
                {
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                catch (Exception)
                { }
            }
        }
    }
}